<template>
        <h3>parent</h3>
         <hr>
        <Child
        :data="data"
        name="zhangsan"
        @myClick = "parentmyclick"
        ref="child"
        />
</template>
    
<script setup lang='ts'>
import { reactive } from '@vue/reactivity';
import { onMounted, ref } from 'vue';
import Child from '../components/child.vue';
// 父传子 子传父
let data = reactive<number[]>([1, 2, 3, 4]);
let parentmyclick = (e) => {
    console.log('子传父：', e);
};


// 从父组件获取子组件实例通过ref
let child = ref(null);
onMounted(() => {
    console.log('通过ref获取的child组件实例：', child.value.childObj);
    child.value.childMethod()
});
</script>
    
<style>
    
</style>